package com.itheima.mapper;

import com.itheima.domain.pojo.Student;
import com.itheima.domain.query.StudentQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @author: Sch
 * @Date: 2025/07/14 19:34
 * @Description:
 */
@Mapper
public interface StudentMapper {

    //分页查询
    List<Student> findStudents(StudentQueryParam studentQueryParam);


    //添加学生
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into student(name,no,gender,phone,id_card,is_college,address,degree,graduation_date,clazz_id,create_time,update_time) values(#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},#{createTime},#{updateTime})")
    void insert(Student student);

    //数据回显
    Student getById(@Param("id") Integer id);

    //修改
    @Update("update student set name = #{name},no = #{no},phone = #{phone},gender = #{gender},degree = #{degree},id_card = #{idCard},is_college = #{isCollege},address = #{address},graduation_date = #{graduationDate},violation_count = #{violationCount},violation_score = #{violationScore},clazz_id = #{clazzId} where id = #{id} ")
    void update(Student student);

    //删除
    void deleteById(@Param("ids") Integer[] ids);

    @MapKey("name")
    List<Map> countStudentDegreeData();

    @MapKey("pos")
    List<Map<String, Object>> countStudentCountData();


}
